import { withKeepAlive } from "keepalive-react-component";
import { lazy } from "react";
import Home from "../views/Home";
// 搭建路由表，没有一开始上来需要用到的使用路由懒加载
const routes = [
  {
    path: "/",
    name: "home",
    component: withKeepAlive(Home, { cacheId: "home", scroll: true }),
    // 路由信息
    meta: {
      title: "知乎日报-WebApp",
    },
  },
  {
    path: "/detail/:id",
    name: "detail",
    component: lazy(() => import("../views/Detail")),
    meta: {
      title: "新闻详情-知乎日报",
    },
  },
  {
    path: "/personal",
    name: "personal",
    component: lazy(() => import("../views/Personal")),
    meta: {
      title: "个人信息-知乎日报",
    },
  },
  {
    path: "/store",
    name: "store",
    component: lazy(() => import("../views/Store")),
    meta: {
      title: "个人收藏-知乎日报",
    },
  },
  {
    path: "/login",
    name: "login",
    component: lazy(() => import("../views/Login")),
    meta: {
      title: "登录注册-知乎日报",
    },
  },
  {
    path: "/update",
    name: "update",
    component: lazy(() => import("../views/Update")),
    meta: {
      title: "修改个人信息-知乎日报",
    },
  },
  {
    path: "*",
    name: "404",
    component: lazy(() => import("../views/Page404")),
    meta: {
      title: "404-知乎日报",
    },
  },
];
export default routes;
